package Controlador;

import Dao.DaoChofer;
import Modelo.Chofer;
import Modelo.Listas;
import Vista.JFrameChoferes;
import Vista.JFrameConsulChoferes;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;

public class ControladorConsulChoferes {

    private JFrameConsulChoferes formConsulChoferes;

    public ControladorConsulChoferes() throws SQLException 
    {
        formConsulChoferes = new JFrameConsulChoferes();
        formConsulChoferes.setLocationRelativeTo(null);
        formConsulChoferes.setVisible(true);
        cargarGridChoferes();
    }

    private void cargarGridChoferes() throws SQLException {
        int Fila = 0;
        String ced, nom, dir,tel,soc,coop;
        ResultSet rgChoferes;
        Dao.DaoChofer daoChofer = new DaoChofer();
        rgChoferes = daoChofer.ConsultarChofer();
        
        while (rgChoferes.next()) 
        {
            //chofer = listaChoferes.getListaChoferes().get(Fila);
            ced = rgChoferes.getString("cedula");
            nom = rgChoferes.getString("nombres");
            dir = rgChoferes.getString("direccion");
            tel = rgChoferes.getString("telefono");
            soc = rgChoferes.getString("ci_socio");
            coop = rgChoferes.getString("codigo_coop");
            formConsulChoferes.getjTableChoferes().setValueAt(ced, Fila, 0);
            formConsulChoferes.getjTableChoferes().setValueAt(nom, Fila, 1);
            formConsulChoferes.getjTableChoferes().setValueAt(dir, Fila, 2);
            formConsulChoferes.getjTableChoferes().setValueAt(tel, Fila, 3);
            formConsulChoferes.getjTableChoferes().setValueAt(soc, Fila, 4);
            formConsulChoferes.getjTableChoferes().setValueAt(coop, Fila, 5);
            Fila++;
        }
    }
}
